package org.example.xx2.common;

public class Result<T> {
    private int status;       // 状态码：0成功，1失败
    private String msg;       // 状态信息
    private T data;           // 响应数据

    public Result() {}
    public Result(int status, String msg, T data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }
    public int getStatus() { return status; }
    public void setStatus(int status) { this.status = status; }
    public String getMsg() { return msg; }
    public void setMsg(String msg) { this.msg = msg; }
    public T getData() { return data; }
    public void setData(T data) { this.data = data; }
    // 成功响应构造方法
    public static <T> Result<T> success(T data, String msg) {
        return new Result<>(0, msg, data);
    }
    // 失败响应构造方法
    public static <T> Result<T> fail(String msg) {
        return new Result<>(1, msg, null);
    }
}